public class TemperatureConverter {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		java.io.PrintStream o = System.out;
		o.println("Welcome to the Tempture Converter!");
		o.println("Type a tempture with its unit and it will be transformed into the other unit.");
		while (true) {
			o.print(">");
			String in = "";
			String realIn = "";
			double value = 0;
			try {
				in = s.nextLine();
				realIn = "" + in;
				java.util.regex.Pattern p = java.util.regex.Pattern
						.compile("\\d+(.\\d+)?");
				java.util.regex.Matcher m = p.matcher(in);
				m.find();
				value = Double.parseDouble(m.group());
			} catch (java.lang.IllegalStateException e) {
				o.println("Assuming Typo");
				continue;
			}

			if (realIn.matches(".*(f|F).*")) {
				o.println("Assuming Fahrenheit");
				o.println("F = (9/5) * C + 32");
				o.println(value + "F = " + ((9d / 5d) * (value + 32)) + "C");
			}
			if (realIn.matches(".*(c|C).*")) {
				o.println("Assuming Celsius");
				o.println("C = (5/9) * (F-32)");
				o.println(value + "C = " + ((5d / 9d) * (value - 32)) + "F");
			}
			if (!realIn.matches(".*(f|F).*")&&realIn.matches(".*(c|C).*"))
			{
				o.println("Assuming Typo");
			}
		}
	}
}
